from tools import all_flow, all_flow_ILAE_861, all_flow_ILAE_860
from global_parameter import ip, port, username, DB_NAME

channel_2v0_scene1 = [
    "NULL, 1, 1, 1, '1', 5, '1', 2, '2023-03-23 15:31:08', NULL, '', 2, '', '1', NULL, NULL, NULL",
    "NULL, 1, 2, 2, '2', 5, '1', 2, '2023-03-23 15:31:08', NULL, '', 2, '', '1', NULL, NULL, NULL"]

no_group_2v0 = ["1, 1, 5, 1",
                "1, 2, 5, 1"]
# 通用算法
algo_2v0_scene1 = [
    "4, '1', '1', '1,3', '0', '', '0', NULL, '2023-04-14 11:44:50', NULL, NULL, NULL, NULL, NULL, 7, 14, 7, 14, '0', '0', '1'"]

# 自适应算法
algo_2v0_scene2 = [
    "4, '2', '1', '1,3', '0', '', '0', NULL, '2023-04-14 11:44:50', NULL, NULL, NULL, NULL, NULL, 7, 14, 7, 14, '0', '0', '1'"]

"""
330kV电压等级对应的字典键值(8)  330kV电压等级线路数  330kV电压等级同源标志(True  False)  330kV电压等级分列标志(True  False)  330kV电压等级停电标志(True  False) 
220kV电压等级对应的字典键值(5)  220kV电压等级线路数  220kV电压等级同源标志(True  False)  220kV电压等级分列标志(True  False)  220kV电压等级停电标志(True  False) 
110kV电压等级对应的字典键值(4)  110kV电压等级线路数  110kV电压等级同源标志(True  False)  110kV电压等级分列标志(True  False)  110kV电压等级停电标志(True  False) 
10kV 电压等级对应的字典键值(3)  10kV 电压等级线路数  10kV 电压等级同源标志(True  False)  10kV 电压等级分列标志(True  False)  10kV 电压等级停电标志(True  False) 
"""
v_arg_2v0_gao_bing = [8, 0, False, False, False,
                      5, 2, False, False, False,
                      4, 0, False, False, False,
                      3, 0, False, False, False]

v_arg_2v0_gao_tong = [8, 0, False, False, False,
                      5, 2, True, False, False,
                      4, 0, False, False, False,
                      3, 0, False, False, False]

v_arg_2v0_gao_fen = [8, 0, False, False, False,
                     5, 2, False, True, False,
                     4, 0, False, False, False,
                     3, 0, False, False, False]

v_arg_2v0_gao_ting = [8, 0, False, False, False,
                      5, 2, False, False, True,
                      4, 0, False, False, False,
                      3, 0, False, False, False]

"""
time_data参数说明：
[-1, 779]
-1：提前一天
779：分钟
"""
# # ILAE-859 计算状态码_未到首次误差评估时间
# # todo 时间问题未解决,暂无法使用
# all_flow_ILAE_859(ip, port, username, DB_NAME, v_arg_2v0_gao_bing, "ILAE-859", channel_2v0_scene1, no_group_2v0,
#                   algo_2v0_scene1, [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
#                   # [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['14', '14'], ['程序异常', '程序异常'], time_data=[-2, 1440 * 4])
#                   [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['14', '14'], ['程序异常', '程序异常'], time_data=[-2, 1 * 4])

# ILAE-860 计算状态码_模拟算法包异常
all_flow_ILAE_860(ip, port, username, DB_NAME, v_arg_2v0_gao_bing, "ILAE-860", channel_2v0_scene1, no_group_2v0,
                  algo_2v0_scene1, [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                  [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['14', '14'], ['程序异常', '程序异常'], time_data=[-2, 1440 * 3])

# ILAE-861 计算状态码_模拟抛异常
all_flow_ILAE_861(ip, port, username, DB_NAME, v_arg_2v0_gao_bing, "ILAE-861", channel_2v0_scene1, no_group_2v0,
                  algo_2v0_scene1, [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                  [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['14', '14'], ['程序异常', '程序异常'], time_data=[-2, 1440 * 3])

# ILAE-863 计算状态码_无采样数据
# 未检查计算时间
all_flow(ip, port, username, DB_NAME, v_arg_2v0_gao_bing, "ILAE-863", channel_2v0_scene1, no_group_2v0, algo_2v0_scene1,
         [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['6', '6'],
         ['无采样数据', '无采样数据'], time_data=[-1, 0], update_sqls=['TRUNCATE da_voltage_data_temp;'])

# ILAE-864 计算状态码_采样数据不足780
all_flow(ip, port, username, DB_NAME, v_arg_2v0_gao_bing, "ILAE-864", channel_2v0_scene1, no_group_2v0, algo_2v0_scene1,
         [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['7', '7'],
         ['采样数据不足780条', '采样数据不足780条'], time_data=[-1, 779])

# ILAE-1137 计算状态码_自适应算法_2V0分列
all_flow(ip, port, username, DB_NAME, v_arg_2v0_gao_fen, "ILAE-1137", channel_2v0_scene1, no_group_2v0,
         algo_2v0_scene2,
         [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['3', '3'],
         ['线路分列运行', '线路分列运行'], time_data=[-1, 780])

# ILAE-1141 计算状态码_自适应算法_2V0同源
all_flow(ip, port, username, DB_NAME, v_arg_2v0_gao_tong, "ILAE-1141", channel_2v0_scene1, no_group_2v0,
         algo_2v0_scene2, [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['2', '2'],
         ['信号同源且同电压等级下无并列运行线路', '信号同源且同电压等级下无并列运行线路'], time_data=[-1, 780])

# ILAE-1143 计算状态码_自适应算法_2V0停电01
all_flow(ip, port, username, DB_NAME, v_arg_2v0_gao_ting, "ILAE-1143", channel_2v0_scene1, no_group_2v0,
         algo_2v0_scene2, [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['3', '1'],
         ['线路分列运行', '线路停电'], time_data=[-1, 780])

# ILAE-1144 计算状态码_自适应算法_2V0停电02
all_flow(ip, port, username, DB_NAME, v_arg_2v0_gao_ting, "ILAE-1144", channel_2v0_scene1, no_group_2v0,
         algo_2v0_scene2, [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['1', '1'],
         ['线路停电', '线路停电'], time_data=[-1, 780], update_sqls=[
        'UPDATE da_voltage_data_temp SET aa_fundamental_amplitude = 5, bb_fundamental_amplitude = 5, cc_fundamental_amplitude = 5 WHERE channel_num=1;'])

# ILAE-1148 计算状态码_通用算法_2V0停电01
all_flow(ip, port, username, DB_NAME, v_arg_2v0_gao_ting, "ILAE-1148", channel_2v0_scene1, no_group_2v0,
         algo_2v0_scene1, [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['3', '1'],
         ['线路分列运行', '线路停电'], time_data=[-1, 780])

# ILAE-1152 计算状态码_通用算法_2V0同源
all_flow(ip, port, username, DB_NAME, v_arg_2v0_gao_tong, "ILAE-1152", channel_2v0_scene1, no_group_2v0,
         algo_2v0_scene1, [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['2', '2'],
         ['信号同源且同电压等级下无并列运行线路', '信号同源且同电压等级下无并列运行线路'], time_data=[-1, 780])

# ILAE-1153 计算状态码_通用算法_2V0分列
all_flow(ip, port, username, DB_NAME, v_arg_2v0_gao_fen, "ILAE-1153", channel_2v0_scene1, no_group_2v0,
         algo_2v0_scene1,
         [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['3', '3'],
         ['线路分列运行', '线路分列运行'], time_data=[-1, 780])

# ILAE-1154 计算状态码_通用算法_2V0停电02
all_flow(ip, port, username, DB_NAME, v_arg_2v0_gao_ting, "ILAE-1154", channel_2v0_scene1, no_group_2v0,
         algo_2v0_scene1, [150, 150, 150, 150, 150, 150], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ['1', '1'],
         ['线路停电', '线路停电'], time_data=[-1, 780], update_sqls=[
        'UPDATE da_voltage_data_temp SET aa_fundamental_amplitude = 5, bb_fundamental_amplitude = 5, cc_fundamental_amplitude = 5 WHERE channel_num=1;'])
